package com.ajhlp.basic.client;


import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

public class Basic implements EntryPoint {
	private final MyConstants constants = GWT.create(MyConstants.class);
	private final BasicServiceAsync basicServiceAsync = GWT.create(BasicService.class);
	@Override
	public void onModuleLoad() {
		// TODO Auto-generated method stub
		RootPanel.get("logout").getElement().setInnerText(constants.logout());
		basicServiceAsync.getUserName(new AsyncCallback<String>() {
					
					@Override
					public void onSuccess(String result) {
						// TODO Auto-generated method stub
						String[] v = result.split(",");
						RootPanel.get("username").getElement().setInnerText(v[0]);
						RootPanel.get("logout").getElement().setAttribute("href", v[1]);
					}
					
					@Override
					public void onFailure(Throwable caught) {
						// TODO Auto-generated method stub
						Window.Location.reload();
					}
				});
		
	}

}
